#include <iostream>
#include "pointer.hpp"

struct any {
    int a;
    int b;
};

void delete_array_int(void * a) {
    delete [](int *)a;
}

int main(int, char**) {
    pointer<int> pint(new int(12));
    pointer<int> pint1;
    std::cout << *pint << std::endl;
    std::cout << pint.count() << std::endl;

    std::cout << "after assigning" << std::endl;

    *pint = 13;
    pint1 = pint;
    std::cout << *pint1 << std::endl;
    std::cout << pint1.count() << std::endl;

    pointer<int> p;
    if(!p) {
        std::cout << "p is null" << std::endl;
    }

    std::cout << "-------------------------------" << std::endl;
    pointer<any > pany(new any);
    pany->a = 12;
    pany->b = 14;
    std::cout << pany->a << std::endl;
    std::cout << pany->b << std::endl;

    pointer<int, delete_array_int> ints(new int[12]);
    for(int i = 0; i < 12; ++i) {
        ((&(*ints)))[i] = i;
    }
    for(int i = 0; i < 12; ++i) {
        std::cout << (&(*ints))[i] << " ";
    }
    std::cout << std::endl;
}
